<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type='text/javascript' src='../js/vue.js'></script>
    <style>
        *{
            margin-top:10px;
        }
        .list{
            width:100px;
            height:100px;
            background-color: bisque;
            overflow: auto;
        }
        .list li{
            width:100px;
            height:60px;
            background-color: #d3d;
        }
    </style>
</head>

<body>
    <!-- 
        修饰符可以连续
        <a gref='https://www.baidu.com' @click.prevent.stop='showInfo'>点我提示信息</a>
      
     -->
    <div id='root'>
        <h2>欢迎{{name}}</h2>
        <!-- 阻止默认事件 -->
        <a href='https://www.baidu.com' @click.prevent='showInfo'>点我提示信息</a>
        <!-- 阻止事件冒泡==>冒泡到父元素 -->
        <div class='demo1' @click.stop='showInfo'>
            <button @click.stop='showInfo'>点击提示信息</button>
        </div>
        <!-- 事件只触发一次 -->
        <button @click.once='showInfo'>点击提示信息</button>

        <!-- 事件捕获模式 改变冒泡顺序  -->
        <div class='box1' @click.capture='showMessage(1)'>
            div1
            <div class='box2' @click='showMessage(2)'>
                div2
            </div>
        </div>

        <!-- 只有event.target是当前元素才触发事件 -->
        <div class='demo' @click.self='showInfo'>
            <button @click='showInfo'>点击提示</button>
        </div>

        <!-- 事件的默认行为立即执行，无需等待事件回调执行完毕 -->
        <ul @wheel.passive='demo' class='list'>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>

    </div>
</body>

<script type='text/javascript'>

    Vue.config.rpoductionTip = false;

    new Vue({
        el: '#root',
        data: {
            name: 'SONG'
        },
        methods: {
            showInfo(event) {

                alert('你好')
            },
            showMessage(e){
                alert(e);
            },
            demo(){
                console.log('!');
            }
        }
    })
</script>

</html>